// $ANTLR 3.1.3 Mar 18, 2009 10:09:25 XHTML2CSV.g 2009-10-13 15:54:57

import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;


import org.antlr.runtime.tree.*;

public class XHTML2CSVParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "CELLULEG", "CELLULED", "LIGNEG", "LIGNED", "TABLED", "LIGNE", "TABLEAU", "CELLULE", "TABLEALIGN", "BORDER", "ENTIER", "FINBALISE", "GUILLEMET", "POS", "CHAINE", "WHITESPACE"
    };
    public static final int LIGNED=7;
    public static final int LIGNEG=6;
    public static final int LIGNE=9;
    public static final int CELLULEG=4;
    public static final int CELLULED=5;
    public static final int TABLEALIGN=12;
    public static final int WHITESPACE=19;
    public static final int CHAINE=18;
    public static final int EOF=-1;
    public static final int TABLEAU=10;
    public static final int BORDER=13;
    public static final int GUILLEMET=16;
    public static final int POS=17;
    public static final int ENTIER=14;
    public static final int TABLED=8;
    public static final int CELLULE=11;
    public static final int FINBALISE=15;

    // delegates
    // delegators


        public XHTML2CSVParser(TokenStream input) {
            this(input, new RecognizerSharedState());
        }
        public XHTML2CSVParser(TokenStream input, RecognizerSharedState state) {
            super(input, state);
             
        }
        
    protected TreeAdaptor adaptor = new CommonTreeAdaptor();

    public void setTreeAdaptor(TreeAdaptor adaptor) {
        this.adaptor = adaptor;
    }
    public TreeAdaptor getTreeAdaptor() {
        return adaptor;
    }

    public String[] getTokenNames() { return XHTML2CSVParser.tokenNames; }
    public String getGrammarFileName() { return "XHTML2CSV.g"; }




    public static class balise_table_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "balise_table"
    // XHTML2CSV.g:27:1: balise_table : TABLEALIGN ( position_table ) BORDER ENTIER FINBALISE milieu TABLED -> ^( TABLEAU milieu ) ;
    public final XHTML2CSVParser.balise_table_return balise_table() throws RecognitionException {
        XHTML2CSVParser.balise_table_return retval = new XHTML2CSVParser.balise_table_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token TABLEALIGN1=null;
        Token BORDER3=null;
        Token ENTIER4=null;
        Token FINBALISE5=null;
        Token TABLED7=null;
        XHTML2CSVParser.position_table_return position_table2 = null;

        XHTML2CSVParser.milieu_return milieu6 = null;


        CommonTree TABLEALIGN1_tree=null;
        CommonTree BORDER3_tree=null;
        CommonTree ENTIER4_tree=null;
        CommonTree FINBALISE5_tree=null;
        CommonTree TABLED7_tree=null;
        RewriteRuleTokenStream stream_TABLEALIGN=new RewriteRuleTokenStream(adaptor,"token TABLEALIGN");
        RewriteRuleTokenStream stream_ENTIER=new RewriteRuleTokenStream(adaptor,"token ENTIER");
        RewriteRuleTokenStream stream_FINBALISE=new RewriteRuleTokenStream(adaptor,"token FINBALISE");
        RewriteRuleTokenStream stream_BORDER=new RewriteRuleTokenStream(adaptor,"token BORDER");
        RewriteRuleTokenStream stream_TABLED=new RewriteRuleTokenStream(adaptor,"token TABLED");
        RewriteRuleSubtreeStream stream_milieu=new RewriteRuleSubtreeStream(adaptor,"rule milieu");
        RewriteRuleSubtreeStream stream_position_table=new RewriteRuleSubtreeStream(adaptor,"rule position_table");
        try {
            // XHTML2CSV.g:27:14: ( TABLEALIGN ( position_table ) BORDER ENTIER FINBALISE milieu TABLED -> ^( TABLEAU milieu ) )
            // XHTML2CSV.g:27:16: TABLEALIGN ( position_table ) BORDER ENTIER FINBALISE milieu TABLED
            {
            TABLEALIGN1=(Token)match(input,TABLEALIGN,FOLLOW_TABLEALIGN_in_balise_table114);  
            stream_TABLEALIGN.add(TABLEALIGN1);

            // XHTML2CSV.g:27:27: ( position_table )
            // XHTML2CSV.g:27:29: position_table
            {
            pushFollow(FOLLOW_position_table_in_balise_table118);
            position_table2=position_table();

            state._fsp--;

            stream_position_table.add(position_table2.getTree());

            }

            BORDER3=(Token)match(input,BORDER,FOLLOW_BORDER_in_balise_table122);  
            stream_BORDER.add(BORDER3);

            ENTIER4=(Token)match(input,ENTIER,FOLLOW_ENTIER_in_balise_table124);  
            stream_ENTIER.add(ENTIER4);

            FINBALISE5=(Token)match(input,FINBALISE,FOLLOW_FINBALISE_in_balise_table126);  
            stream_FINBALISE.add(FINBALISE5);

            pushFollow(FOLLOW_milieu_in_balise_table128);
            milieu6=milieu();

            state._fsp--;

            stream_milieu.add(milieu6.getTree());
            TABLED7=(Token)match(input,TABLED,FOLLOW_TABLED_in_balise_table130);  
            stream_TABLED.add(TABLED7);



            // AST REWRITE
            // elements: milieu
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 28:3: -> ^( TABLEAU milieu )
            {
                // XHTML2CSV.g:28:6: ^( TABLEAU milieu )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(TABLEAU, "TABLEAU"), root_1);

                adaptor.addChild(root_1, stream_milieu.nextTree());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "balise_table"

    public static class position_table_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "position_table"
    // XHTML2CSV.g:30:1: position_table : GUILLEMET POS GUILLEMET ;
    public final XHTML2CSVParser.position_table_return position_table() throws RecognitionException {
        XHTML2CSVParser.position_table_return retval = new XHTML2CSVParser.position_table_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token GUILLEMET8=null;
        Token POS9=null;
        Token GUILLEMET10=null;

        CommonTree GUILLEMET8_tree=null;
        CommonTree POS9_tree=null;
        CommonTree GUILLEMET10_tree=null;

        try {
            // XHTML2CSV.g:30:16: ( GUILLEMET POS GUILLEMET )
            // XHTML2CSV.g:30:18: GUILLEMET POS GUILLEMET
            {
            root_0 = (CommonTree)adaptor.nil();

            GUILLEMET8=(Token)match(input,GUILLEMET,FOLLOW_GUILLEMET_in_position_table150); 
            GUILLEMET8_tree = (CommonTree)adaptor.create(GUILLEMET8);
            adaptor.addChild(root_0, GUILLEMET8_tree);

            POS9=(Token)match(input,POS,FOLLOW_POS_in_position_table152); 
            POS9_tree = (CommonTree)adaptor.create(POS9);
            adaptor.addChild(root_0, POS9_tree);

            GUILLEMET10=(Token)match(input,GUILLEMET,FOLLOW_GUILLEMET_in_position_table154); 
            GUILLEMET10_tree = (CommonTree)adaptor.create(GUILLEMET10);
            adaptor.addChild(root_0, GUILLEMET10_tree);


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "position_table"

    public static class milieu_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "milieu"
    // XHTML2CSV.g:32:1: milieu : ( ldlg )* ;
    public final XHTML2CSVParser.milieu_return milieu() throws RecognitionException {
        XHTML2CSVParser.milieu_return retval = new XHTML2CSVParser.milieu_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        XHTML2CSVParser.ldlg_return ldlg11 = null;



        try {
            // XHTML2CSV.g:32:8: ( ( ldlg )* )
            // XHTML2CSV.g:32:11: ( ldlg )*
            {
            root_0 = (CommonTree)adaptor.nil();

            // XHTML2CSV.g:32:11: ( ldlg )*
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( (LA1_0==LIGNEG) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // XHTML2CSV.g:32:12: ldlg
            	    {
            	    pushFollow(FOLLOW_ldlg_in_milieu165);
            	    ldlg11=ldlg();

            	    state._fsp--;

            	    adaptor.addChild(root_0, ldlg11.getTree());

            	    }
            	    break;

            	default :
            	    break loop1;
                }
            } while (true);


            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "milieu"

    public static class ldlg_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "ldlg"
    // XHTML2CSV.g:34:1: ldlg : LIGNEG ( cellule )* LIGNED -> ^( LIGNE ( cellule )* ) ;
    public final XHTML2CSVParser.ldlg_return ldlg() throws RecognitionException {
        XHTML2CSVParser.ldlg_return retval = new XHTML2CSVParser.ldlg_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token LIGNEG12=null;
        Token LIGNED14=null;
        XHTML2CSVParser.cellule_return cellule13 = null;


        CommonTree LIGNEG12_tree=null;
        CommonTree LIGNED14_tree=null;
        RewriteRuleTokenStream stream_LIGNED=new RewriteRuleTokenStream(adaptor,"token LIGNED");
        RewriteRuleTokenStream stream_LIGNEG=new RewriteRuleTokenStream(adaptor,"token LIGNEG");
        RewriteRuleSubtreeStream stream_cellule=new RewriteRuleSubtreeStream(adaptor,"rule cellule");
        try {
            // XHTML2CSV.g:34:6: ( LIGNEG ( cellule )* LIGNED -> ^( LIGNE ( cellule )* ) )
            // XHTML2CSV.g:34:8: LIGNEG ( cellule )* LIGNED
            {
            LIGNEG12=(Token)match(input,LIGNEG,FOLLOW_LIGNEG_in_ldlg176);  
            stream_LIGNEG.add(LIGNEG12);

            // XHTML2CSV.g:34:15: ( cellule )*
            loop2:
            do {
                int alt2=2;
                int LA2_0 = input.LA(1);

                if ( (LA2_0==CELLULEG) ) {
                    alt2=1;
                }


                switch (alt2) {
            	case 1 :
            	    // XHTML2CSV.g:34:16: cellule
            	    {
            	    pushFollow(FOLLOW_cellule_in_ldlg179);
            	    cellule13=cellule();

            	    state._fsp--;

            	    stream_cellule.add(cellule13.getTree());

            	    }
            	    break;

            	default :
            	    break loop2;
                }
            } while (true);

            LIGNED14=(Token)match(input,LIGNED,FOLLOW_LIGNED_in_ldlg183);  
            stream_LIGNED.add(LIGNED14);



            // AST REWRITE
            // elements: cellule
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 35:3: -> ^( LIGNE ( cellule )* )
            {
                // XHTML2CSV.g:35:6: ^( LIGNE ( cellule )* )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(LIGNE, "LIGNE"), root_1);

                // XHTML2CSV.g:35:14: ( cellule )*
                while ( stream_cellule.hasNext() ) {
                    adaptor.addChild(root_1, stream_cellule.nextTree());

                }
                stream_cellule.reset();

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "ldlg"

    public static class cellule_return extends ParserRuleReturnScope {
        CommonTree tree;
        public Object getTree() { return tree; }
    };

    // $ANTLR start "cellule"
    // XHTML2CSV.g:37:1: cellule : CELLULEG CHAINE CELLULED -> ^( CELLULE CHAINE ) ;
    public final XHTML2CSVParser.cellule_return cellule() throws RecognitionException {
        XHTML2CSVParser.cellule_return retval = new XHTML2CSVParser.cellule_return();
        retval.start = input.LT(1);

        CommonTree root_0 = null;

        Token CELLULEG15=null;
        Token CHAINE16=null;
        Token CELLULED17=null;

        CommonTree CELLULEG15_tree=null;
        CommonTree CHAINE16_tree=null;
        CommonTree CELLULED17_tree=null;
        RewriteRuleTokenStream stream_CHAINE=new RewriteRuleTokenStream(adaptor,"token CHAINE");
        RewriteRuleTokenStream stream_CELLULEG=new RewriteRuleTokenStream(adaptor,"token CELLULEG");
        RewriteRuleTokenStream stream_CELLULED=new RewriteRuleTokenStream(adaptor,"token CELLULED");

        try {
            // XHTML2CSV.g:37:9: ( CELLULEG CHAINE CELLULED -> ^( CELLULE CHAINE ) )
            // XHTML2CSV.g:37:11: CELLULEG CHAINE CELLULED
            {
            CELLULEG15=(Token)match(input,CELLULEG,FOLLOW_CELLULEG_in_cellule206);  
            stream_CELLULEG.add(CELLULEG15);

            CHAINE16=(Token)match(input,CHAINE,FOLLOW_CHAINE_in_cellule208);  
            stream_CHAINE.add(CHAINE16);

            CELLULED17=(Token)match(input,CELLULED,FOLLOW_CELLULED_in_cellule210);  
            stream_CELLULED.add(CELLULED17);



            // AST REWRITE
            // elements: CHAINE
            // token labels: 
            // rule labels: retval
            // token list labels: 
            // rule list labels: 
            // wildcard labels: 
            retval.tree = root_0;
            RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.tree:null);

            root_0 = (CommonTree)adaptor.nil();
            // 38:3: -> ^( CELLULE CHAINE )
            {
                // XHTML2CSV.g:38:6: ^( CELLULE CHAINE )
                {
                CommonTree root_1 = (CommonTree)adaptor.nil();
                root_1 = (CommonTree)adaptor.becomeRoot((CommonTree)adaptor.create(CELLULE, "CELLULE"), root_1);

                adaptor.addChild(root_1, stream_CHAINE.nextNode());

                adaptor.addChild(root_0, root_1);
                }

            }

            retval.tree = root_0;
            }

            retval.stop = input.LT(-1);

            retval.tree = (CommonTree)adaptor.rulePostProcessing(root_0);
            adaptor.setTokenBoundaries(retval.tree, retval.start, retval.stop);

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
    	retval.tree = (CommonTree)adaptor.errorNode(input, retval.start, input.LT(-1), re);

        }
        finally {
        }
        return retval;
    }
    // $ANTLR end "cellule"

    // Delegated rules


 

    public static final BitSet FOLLOW_TABLEALIGN_in_balise_table114 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_position_table_in_balise_table118 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_BORDER_in_balise_table122 = new BitSet(new long[]{0x0000000000004000L});
    public static final BitSet FOLLOW_ENTIER_in_balise_table124 = new BitSet(new long[]{0x0000000000008000L});
    public static final BitSet FOLLOW_FINBALISE_in_balise_table126 = new BitSet(new long[]{0x0000000000000140L});
    public static final BitSet FOLLOW_milieu_in_balise_table128 = new BitSet(new long[]{0x0000000000000100L});
    public static final BitSet FOLLOW_TABLED_in_balise_table130 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_GUILLEMET_in_position_table150 = new BitSet(new long[]{0x0000000000020000L});
    public static final BitSet FOLLOW_POS_in_position_table152 = new BitSet(new long[]{0x0000000000010000L});
    public static final BitSet FOLLOW_GUILLEMET_in_position_table154 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_ldlg_in_milieu165 = new BitSet(new long[]{0x0000000000000042L});
    public static final BitSet FOLLOW_LIGNEG_in_ldlg176 = new BitSet(new long[]{0x0000000000000090L});
    public static final BitSet FOLLOW_cellule_in_ldlg179 = new BitSet(new long[]{0x0000000000000090L});
    public static final BitSet FOLLOW_LIGNED_in_ldlg183 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_CELLULEG_in_cellule206 = new BitSet(new long[]{0x0000000000040000L});
    public static final BitSet FOLLOW_CHAINE_in_cellule208 = new BitSet(new long[]{0x0000000000000020L});
    public static final BitSet FOLLOW_CELLULED_in_cellule210 = new BitSet(new long[]{0x0000000000000002L});

}